package com.wen.task;

import com.wen.entry.Result;
import com.wen.moudle.Account;
import com.wen.moudle.Managers.*;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class AbstractTask {

    protected final Account account;  // 账户管理
    private FightManager fightManager;  // 战斗管理
    private ShopManager shopManager;  // 商店管理
    private InformationManager informationManager;  // 人物状态管理
    private BackpackManager backpackManager;  // 背包管理
    private EquipmentManager equipmentManager;  // 装备管理


    protected FightManager getFightManager() {
        if (fightManager == null){
            fightManager = new FightManager(account);
        }
        return fightManager;
    }


    protected ShopManager getShopManager() {
        if (shopManager == null){
            shopManager = new ShopManager(account);
        }
        return shopManager;
    }

    protected InformationManager getInformationManager() {
        if (informationManager == null){
            informationManager = new InformationManager(account);
        }
        return informationManager;
    }

    protected BackpackManager getBackpackManager() {
        if (backpackManager == null){
            backpackManager = new BackpackManager(account);
        }
        return backpackManager;
    }

    protected EquipmentManager getEquipmentManager() {
        if (equipmentManager == null){
            equipmentManager = new EquipmentManager(account);
        }
        return equipmentManager;
    }

    public AbstractTask(Account account) {
        this.account = account;
    }

    protected boolean login(){
        log.info("开始登录");
        Result<String> result = account.login();
        return result.isSuccess();
    }

    protected boolean logout(){
        log.info("退出账号");
        Result<String> result = account.logout();
        return result.isSuccess();
    }


    public abstract void run();


    // 帮助说明
    public String getDetail(){
        return "无说明";
    }

    // 展示出来的标题名
    public abstract String getTitle();


}

